{__NOLAYOUT__}
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<title>登录</title>
		<link rel="stylesheet" href="/static/admin/site.css" />
	</head>
	<body class="login">
		<form action="{:request()->url()}" method="post" class="form-ajax">
			<h1>快排CMS</h1>
			<h2></h2>
			<div>
				<input type="text" name="name" placeholder="请输入用户名" data-rule="required" class="input" autocomplete="off">
			</div>
			<div>
				<input type="password" name="pass" placeholder="请输入密码" data-rule="required" class="input" autocomplete="off">
			</div>
			<div>
				<button type="submit" class="btn" id="sub">登录</button>
			</div>
		</form>
		<script src="/static/js/jquery.min.js"></script>
		<script src="/static/js/layer/layer.js"></script>
		<script src="/static/js/jquery.form.min.js"></script>
		<script src="/static/js/validator/jquery.validator.min.js?local=zh-CN"></script>
		<script>
			$(function() {
				$('.form-ajax').on('valid.form', function() {
					$(this).ajaxSubmit({
						beforeSend: function(e) {
							var sub = $('.ajax-form').find("#sub");
							sub.data("title", sub.html()).html("提交中").attr("disabled", "disabled");
							layer.load(2, {
								shade: [0.1, '#000']
							});
						},
						error: function(e) {
							layer.closeAll('loading');
							var sub = $('.ajax-form').find("#sub");
							sub.html(sub.data("title")).removeAttr("disabled", "disabled");
							layer.alert("提交失败！");
						},
						success: function(data) {
							console.log(data);
							layer.closeAll('loading');
							var sub = $('.ajax-form').find("#sub");
							sub.html(sub.data("title")).removeAttr("disabled", "disabled");
							if (data.msg) {
								layer.msg(data.msg, {
									icon: data.code,
									shade: [0.1, '#000'],
									time: 1500
								}, function() {
									if (data.url) {
										location.href = data.url;
									}
								});
							} else if (data.url) {
								location.href = data.url;
							}
						}
					});
					return false;
				});
			})
		</script>
	</body>
</html>
